package org.qiyu.live.im.core.server.common;

import io.netty.channel.ChannelHandlerContext;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description: 管理
 * @Author: 张广焱
 * @Date: 2024-05-02 下午8:00
 */
    public class ChannelHandlerContextCache {

    /**
     * @Description: 当前im服务启动的时候,对外暴露的ip和端口
     * @Author: 张广焱
     * @Date: 2024-05-04  17:04:28
     */
    private static String SERVER_IP_ADDRESS="";

    public static String getServerIpAddress() {
        return SERVER_IP_ADDRESS;
    }

    public static void setServerIpAddress(String serverIpAddress) {
        SERVER_IP_ADDRESS = serverIpAddress;
    }

    private static Map<Long, ChannelHandlerContext> channelHandlerContextMap = new HashMap<>();

    /**
     * @Description: 查询
     * @Author: 张广焱
     * @Date: 2024-05-02  20:03:19
     */
    public static ChannelHandlerContext get(long userId) {
        return channelHandlerContextMap.get(userId);
    }

    /**
     * @Description: 存放
     * @Author: 张广焱
     * @Date: 2024-05-02  20:04:28
     */
    public static void push(long userId, ChannelHandlerContext channelHandlerContext) {
        channelHandlerContextMap.put(userId, channelHandlerContext);
    }

    /**
     * @Description: 删除
     * @Author: 张广焱
     * @Date: 2024-05-02  20:04:45
     */
    public static void remove(long userId) {
        channelHandlerContextMap.remove(userId);
    }

    public static void put(Long userId, ChannelHandlerContext ctx) {
    }
}
